package com.jeff.serviceImpl;

import com.jeff.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jeff.mapper.DeptMapper;
import com.jeff.mybatis.page.Page;
import com.jeff.po.Dept;
import com.jeff.service.DeptService;


@Service
public class DeptServiceImpl extends BaseServiceImpl<Dept, String>implements DeptService {

	@Autowired
	private DeptMapper deptMapper;

	@Autowired
	public void setBaseMapper() {
		super.setBaseMapper(deptMapper);
	}

	@Override
	public Page<Dept> findparentDeptByPage(Dept dept) {
		return this.buildPage(deptMapper.findparentDeptByPage(dept));
	}

    @Override
    public String getRootDeptId(String id) {
		Dept dept = this.getById(id);
		if(StringUtil.isNotEmpty(dept.getParentId())){
			return dept.getParentId();
		}
		return id;
    }


}
